package demo5;

public class Test {

    public static void main(String[] args) {
        Myvalue myvalue1 = new Myvalue();
        Myvalue myvalue2 = new Myvalue();

        myvalue1.val = 10;
        myvalue2 .val = 20;
        System.out.println("交换前: a: " + myvalue1.val + " b: " + myvalue2 .val);
        swap1(myvalue1,myvalue2);
        System.out.println("交换后: a: " + myvalue1.val + " b: " + myvalue2 .val);
    }

    private static void swap1(Myvalue myvalue1, Myvalue myvalue2) {
        int tmp = myvalue1.val;
        myvalue1.val = myvalue2.val;
        myvalue2.val = tmp;
    }

    public static void main1(String[] args) {
        int a = 10;
        int b = 20;
        System.out.println("交换前: a: " + a + " b: " + b);
        swap(a,b);
        System.out.println("交换后: a: " + a + " b: " + b);
    }

    private static void swap(int a, int b) {
        int tmp = a;
        a = b;
        b = tmp;
    }
}
